InventorySlot

Kind of class:class
Inherits from:DragTarget < UIComponent < MovieClip
Classpath:gfx.controls.InventorySlot
File last modified:Tuesday, 29 June 2010, 09:03:27
Displays an inventory "item" with quantity, and uses DragManager to allow dragging and dropping items between InventorySlots with compatible dragAcceptTypes.

This class does not provide for other user interaction with the inventory, such as clicking. @see ItemSlot For button like interaction, see the ItemSlot.

This component uses an icons movieclip to display items, but it could be extended to support external images or texture substitution.

Constructor

InventorySlot

function InventorySlot (
)

The constructor is called when a InventorySlot or a sub-class of InventorySlot is instantiated on stage or by using attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend InventorySlot, ensure that a super() call is made first in the constructor.

Instance properties

data

data:Object
(read,write)

The data object representing the item to be displayed. Inventory slot expects the object to have type, quantity. and asset properties. The asset property specifies the frame or label to display in the icons MovieClip.

Event handlers

allowDrop

function allowDrop (
data:Object) : Boolean

Determines if the DragTarget instance will accept the specified data object. Similar to DragTarget.allowDrop it matches the data object's "type" property against the types specified in dragAcceptTypes, but also adds a check to ensure that it will be able to swap data with the origin
Parameters:
data:
The data object to check.
Returns:
  • Whether the drop was accepted (true) or not (false).